package com.sqq.jfinalbase;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.Properties;

import com.jfinal.config.JFinalConfig;

public abstract class SqqJFinalConfig extends JFinalConfig {
	public Properties loadPropertyFile(String file) {
        Properties properties=null;
        try {
            properties = new Properties();
            InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(file);
            properties.load(resourceAsStream);
            Field field = JFinalConfig.class.getDeclaredField("properties");
            field.setAccessible(true);
            field.set(this, properties);
            field.setAccessible(false);
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IOException e) {
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        return properties;
    }
}
